package com.booway.demo.common.statics.utils;

import java.util.Map;
import java.util.UUID;
import java.util.Collection;
import java.lang.reflect.Array;

/**
 * 工具类
 * @author jsb-hujie
 * 
 * 2019年5月9日
 *
 */
public class CommonUtil
{
	private CommonUtil() { }
	
    public void sayHello() 
    {
        System.out.println("HelloWorld!");
    }

    public void xxxxxxx()
    {
        System.out.println("HelloWorldxxxxx!");
    }
    
    public void demoTest()
    {
    	System.out.println("------------>");
    }
	/**
	 * 获取UUID字符串
	 * @return
	 */
	public static String getUUID()
	{
		return UUID.randomUUID().toString();
	}
	/**
	 * uuid去除横杠
	 * @return
	 */
	public static String getUid()
	{
		return UUID.randomUUID().toString().replaceAll("-", "");
	}
	/**
	 * 判断是否为空
	 * @param obj 需要判断的对象, 空集合也算是空
	 * @return
	 */
	public static boolean isEmpty(Object obj)
	{
		if (null == obj)
		{
			return true;
		} else if (obj instanceof String)
		{
			return obj.toString().trim().length() == 0;
		} else if (obj instanceof Collection)
		{
			Collection<?> coll = (Collection<?>) obj;
			return coll.size() == 0;
		} else if (obj instanceof Map)
		{
			Map<?, ?> map = (Map<?, ?>) obj;
			return map.size() == 0;
		} else if (obj.getClass().isArray())
		{
			return Array.getLength(obj) == 0;
		}
		return false;
	}
	/**
	 * 判断非空
	 * @param obj
	 * @return
	 */
	public static boolean isNotEmpty(Object obj)
	{
		return !isEmpty(obj);
	}
}
